package com.example.demo.models.user;

import com.example.demo.models.base.Authenticatable;
import com.example.demo.models.base.BaseEntity;
import com.example.demo.models.base.JWTSubject;
import gaarason.database.annotation.Column;
import gaarason.database.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.stereotype.Repository;

/**
 * @author lucifer
 * @since 2024-01-30-12:06
 */
@Data
@ToString(callSuper = true)
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Table(name = "users")
public class User extends BaseEntity implements JWTSubject, Authenticatable {
    private static final long serialVersionUID = 1L;

    /**
     * auto generator start
     **/
    @Column(name = "number", comment = "学生：学号 老师：工号")
    private String number;

    @Column(name = "name", nullable = true, comment = "姓名")
    private String name;

    @Column(name = "gender", nullable = true, comment = "性别")
    private String gender;

    @Column(name = "grade", nullable = true, comment = "年级")
    private String grade;

    @Column(name = "college", nullable = true, comment = "学院")
    private String college;

    @Column(name = "major", nullable = true, comment = "专业")
    private String major;

    @Column(name = "clazz", nullable = true, comment = "班级")
    private String clazz;

    @Override
    public String getJWTIdentifier() {
        return String.valueOf(this.getId());
    }

    @Override
    public String getJWTClassId() {
        return "48074923";
    }

    /**
     * auto generator end
     **/
    @Repository
    public static class Model extends BaseModel<User, Long> {
        @Override
        protected boolean softDeleting() {
            return true;
        }
    }
}